Next: Defining New Widgets, Previous: Sexp Types, Up: Top [Contents][Index]
You can examine or set the value of a widget by using the
widget object that was returned by
widget-create.
Return the current value contained in widget. It is an error to call this function on an uninitialized widget.
Set the value contained in widget to value. It is an error to call this function with an invalid value.
Important: You must call
widget-setup after modifying the value of a widget
before the user is allowed to edit the widget again. It is enough
to call widget-setup once if you modify multiple
widgets. This is currently only necessary if the widget contains
an editing field, but may be necessary for other widgets in the
future.
If your application needs to associate some information with
the widget objects, for example a reference to the item being
edited, it can be done with widget-put and
widget-get. The property names must begin with a
‘:’.
In widget set property to value. property should be a symbol, while value can be anything.
In widget return the value for
property. property should be a symbol,
the value is what was last set by widget-put for
property.
Non-nil if widget has a value
(even nil) for property property.
Occasionally it can be useful to know which kind of widget you have, i.e., the name of the widget type you gave when the widget was created.
Return the name of widget, a symbol.
Widgets can be in two states: active, which means they are modifiable by the user, or inactive, which means they cannot be modified by the user. You can query or set the state with the following code:
;; Examine if widget is active or not.
(if (widget-apply widget :active)
(message "Widget is active.")
(message "Widget is inactive.")
;; Make widget inactive.
(widget-apply widget :deactivate)
;; Make widget active.
(widget-apply widget :activate)
A widget is inactive if it, or any of its ancestors (found by
following the :parent link), have been deactivated.
To make sure a widget is really active, you must therefore
activate both it and all its ancestors.
(while widget (widget-apply widget :activate) (setq widget (widget-get widget :parent)))
You can check if a widget has been made inactive by examining
the value of the :inactive keyword. If this is
non-nil, the widget itself has been deactivated.
This is different from using the :active keyword, in
that the latter tells you if the widget or any
of its ancestors have been deactivated. Do not attempt to set the
:inactive keyword directly. Use the
:activate :deactivate keywords
instead.
Next: Defining New Widgets, Previous: Sexp Types, Up: Top [Contents][Index]